package com.cea.papyrus.diagram.statemachine.editpart;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.tools.DragEditPartsTracker;

/**
 * A specific drag tracker for regions. It locally stores the potential target edit part 
 * during a drag and drop.
 *  
 * @author David Servat
 * @since 29 jan. 07
 */
public class RegionDragTracker extends DragEditPartsTracker{

	/** The RegionEditPart. */
	protected RegionEditPart regionEP = null;
	
	/** The TargetEditPart. */
	protected EditPart targetEP = null;
	
	/**
	 * The Constructor.
	 * 
	 * @param regionEditPart the RegionEditPart
	 */
	public RegionDragTracker(RegionEditPart regionEditPart){
		super(regionEditPart);
		
		this.regionEP = regionEditPart;
	}

	/**
	 * This method is overriden to locally store the TargetEditPart.
	 * 
	 * @return the target EditPart
	 */
	@Override
	protected EditPart getTargetEditPart(){
		targetEP = super.getTargetEditPart();
		return targetEP;
	}
	
	/**
	 * This method returns the target RegionEditPart if any, or returns null.
	 * 
	 * @return the target RegionEditPart
	 */
	public RegionEditPart getTargetRegionEditPart(){
		if((targetEP != null) && (targetEP instanceof RegionEditPart))
			return (RegionEditPart)targetEP;
		return null;
	}
}
